using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Android.App;
using Android.Content;
using Android.Graphics.Drawables;
using Android.OS;
using Android.Runtime;
using Android.Views;
using SpotOffer.CustomViews;
using SpotOffer.Droid.CustomRenderer;
using SpotOffer.Resource;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;

[assembly:ExportRenderer(typeof(MenuTableView), typeof(MenuTableViewRenderer))]
namespace SpotOffer.Droid.CustomRenderer
{
    public class MenuTableViewRenderer : ListViewRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<ListView> e)
        {
            base.OnElementChanged(e);

            if (Control == null)
                return;

            var listView = Control as global::Android.Widget.ListView;
            listView.DividerHeight = 0;

            StateListDrawable backSelector = new StateListDrawable();
            var transpColor = AppColors.White.ToAndroid();

            backSelector.AddState(new[] { Android.Resource.Attribute.StateFocused }, new ColorDrawable(transpColor));
            backSelector.AddState(new[] { Android.Resource.Attribute.StateFocused }, new ColorDrawable(transpColor));
            backSelector.AddState(new[] { Android.Resource.Attribute.StatePressed }, new ColorDrawable(transpColor));
            //  backSelector.AddState(new[] { Android.Resource.Attribute.StateSelected }, new ColorDrawable(transpColor));
            backSelector.AddState(new[] { Android.Resource.Attribute.StateFirst }, new ColorDrawable(new Android.Graphics.Color(0, 0, 0, 0)));
            listView.Selector = backSelector;
        }
    }
}